home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Unreal Tournament Game Programming for Teens
/
UnrealTournamentGameProgrammingForTeens.iso
/
Chapter Files
/
Chapter06
/
AddNumbersTrigger.txt
next >
Wrap
Text File
|
2006-10-14
|
2KB
|
54 lines
//=============================================================================
// AddNumbersTrigger.
//=============================================================================
class AddNumbersTrigger extends Trigger placeable;
var (Message) string NumbersMessage;
//#1
//Data member for Math class
var private Math NumberFromMath;
//Data members for random numbers
var private int RandNumberA,
RandNumberB;
function PostBeginPlay(){
Super.PostBeginPlay();
//#2
//Set the values here rather than in the
//the Properties dialog
ReTriggerDelay = 1.0;
RepeatTriggerTime = 2.5;
bHidden = true;
//#3 Generate the random numbers
// and assign them to the data members
RandNumberA = Rand(25);
RandNumberB = Rand(25);
//#4 Pass the arguments to the function
NumbersMessage = GetMessage(RandNumberA ,RandNumberB );
Message = NumbersMessage;
}
public function string GetMessage(int FirstNum,
int SecondNum){
local string NumberString;
local int SumOfNumbers;
//#5 Create an instance of the Math class
NumberFromMath = spawn(class 'Math');
//#6 Use the instance of the Math class to
// call the Add() Method
// Convert the float to an intger
// Create a text message
SumOfNumbers = Int(NumberFromMath.Add(FirstNum, SecondNum));
NumberString = FirstNum @ " added to " @ SecondNum
@ " is "
@ SumOfNumbers ;
return NumberString;
}